package com.example;

/**
 * @desc:
 * @author: Shoko
 * @date: 2025/5/25
 */
// 打印机类
public class Printer {
    private String name;
    private double price;
    private DiscountStrategy discountStrategy;

    public Printer(String name, double price) {
        this.name = name;
        this.price = price;
        this.discountStrategy = new NoDiscountStrategy(); // 默认无折扣
    }

    public void setDiscountStrategy(DiscountStrategy discountStrategy) {
        this.discountStrategy = discountStrategy;
    }

    public double calculatePrice() {
        return discountStrategy.calculate(price);
    }

    // Getter方法
    public String getName() {
        return name;
    }

    public double getPrice() {
        return price;
    }
}
